package com.park.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {



    @Bean
    public Docket docket(){
        //链式编程(构建器模式)
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.park.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * 创建api的基本信息
     * @return
     */
    @Bean
    ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("test标题")
                .description("描述")
                .termsOfServiceUrl("服务条款")
                .contact(new Contact("联系人","网址","email"))
                .license("许可证")
                .licenseUrl("许可证网址")
                .version("2.0.0版本")
                .build();
    }
}
